const express = require("express");
const cors = require("cors");
const app = express();

let loginRouter = express.Router();
loginRouter.get("/", (req, res) => {
  //http://localhost:3000/login?a=1&b=2
  //{ a: '1', b: '2' }
  console.log(req.query);
  res.send("login");
});

// 接收post请求
loginRouter.post("/", (req, res) => {
  //http://localhost:3000/login?a=1&b=2
  //{ a: '1', b: '2' }
  console.log(req.body);
  res.send({status:"ok"});
});

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cors());
app.use("/login", loginRouter);

app.listen(3000, () => {
  console.log("3000");
});
